package com.hspedu.newData.dmsxl.树.二叉搜索树的操作;

import com.hspedu.newData.dmsxl.ds.TreeNode;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-19 
 * @Version: 1.0
 */

public class LC701二叉搜索树中的插入操作 {

    public TreeNode insertIntoBST(TreeNode root, int val) {

        if (root == null){
            TreeNode treeNode = new TreeNode(val);
            return treeNode;
        }

        if (root.val > val){
            root.left = insertIntoBST(root.left,val);
        }
        if (root.val < val){
            root.right = insertIntoBST(root.right,val);
        }
        return root;
    }

}
